#include<bits/stdc++.h>
using namespace std;
int t, n, m, l, v, p[10005];
struct T{
    double di, ai, vi;
    double fro, endd;
}s[10005];
double e(double d){
    double u=0, r=100000, exp=0.00001, mid=0;
    while(mid*mid>d+exp&&mid*mid<d-exp)
    {
        mid=(u+r)/2;
        if(mid*mid<d)
        {
            u=mid;
        }
        else if(mid*mid>d)
        {
            r=mid;
        }
    }
    return mid;
}
bool cmp(T x , T c){
    return x.endd<c.endd;
}
struct R{
    vector q;
}j[10005];
int main()
{
    freopen("detect.in","w",stdin);
    freopen("detect.out","r",stdout);
    cin>>t;
    for(int y=1;y<=t;y++)
    {
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++)
        {
            cin>>s[i].di>>s[i].vi>>s[i].ai;
            if(s[i].ai<0)
            {
                if(s[i].vi>v)
                {
                    s[i].fro=s[i].di;
                    double t=(v-s[i].vi)/s[i].ai;
                    s[i].endd=s[i].di+(s[i].vi*t)+(0.5*s[i].ai*t*t);
                }
            }
            else if(s[i].ai==0)
            {
                if(s[i].vi>v)
                {
                    s[i].fro=s[i].di;
                    s[i].endd=l;
                }
            }
            else if(s[i].ai>0)
            {
                if(s[i].vi>v)
                {
                    s[i].fro=s[i].di;
                    s[i].endd=l;
                }
                else if(s[i].vi<=v)
                {
                    double f=(v-s[i].vi)/s[i].ai;
                    s[i].fro=s[i].di+(s[i].vi*f)+(0.5*s[i].ai*f*f);
                    s[i].endd=l;
                }
            }

        }
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
        }
        sort(p+1,p+n+1,cmp);
        for(int i=)
    }
    return 0;
}
